home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Syn Text Editor 2.1.0.46 / synsetup-2.1.0.46.exe / {app} / scripts / gplheader.js < prev    next >
Text File  |  2003-08-13  |  5KB  |  122 lines

  1. // Caption: Add &GPL Header|
  2. // Hint: Add GPL Header at the Top|
  3. // Icon: gpl.ico|
  4. /*
  5.   syn
  6.   Copyright (C) 2000-2003, Ascher Stefan. All rights reserved.
  7.   stievie@utanet.at, http://web.utanet.at/ascherst/
  8.  
  9.   The contents of this file are subject to the Mozilla Public License
  10.   Version 1.1 (the "License"); you may not use this file except in compliance
  11.   with the License. You may obtain a copy of the License at
  12.   http://www.mozilla.org/MPL/
  13.  
  14.   Software distributed under the License is distributed on an "AS IS" basis,
  15.   WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  16.   the specific language governing rights and limitations under the License.
  17.  
  18.   The Original Code is gplheader.js.js, released Wed, 22 May 2002 10:37:17 UTC.
  19.  
  20.   The Initial Developer of the Original Code is Ascher Stefan.
  21.   Portions created by Ascher Stefan are Copyright (C) 2000-2003 Ascher Stefan.
  22.   All Rights Reserved.
  23.  
  24.   Contributor(s): .
  25.  
  26.   Alternatively, the contents of this file may be used under the terms of the
  27.   GNU General Public License Version 2 or later (the "GPL"), in which case
  28.   the provisions of the GPL are applicable instead of those above.
  29.   If you wish to allow use of your version of this file only under the terms
  30.   of the GPL and not to allow others to use your version of this file
  31.   under the MPL, indicate your decision by deleting the provisions above and
  32.   replace them with the notice and other provisions required by the GPL.
  33.   If you do not delete the provisions above, a recipient may use your version
  34.   of this file under either the MPL or the GPL.
  35.  
  36.   You may retrieve the latest version of this file at the syn home page,
  37.   located at http://syn.sourceforge.net/
  38.  
  39.  $Id: gplheader.js,v 1.2.2.5 2003/08/13 00:38:45 neum Exp $
  40. */
  41.  
  42. //#include <consts>
  43. //#include <cmnfunc>
  44.  
  45. function Main()
  46. {
  47.   Author = 'Ascher Stefan';
  48.   Email = 'stievie@utanet.at';
  49.   Contribs = '';
  50.   URL1 = 'http://web.utanet.at/ascherst/';
  51.   gpl = new Array(
  52.     '',
  53.     '$[Project]',                                                 /* You may want to modify this tree lines */
  54.     'Copyright (C) $[Year], $[Author]. All rights reserved.',
  55.     '$[Email], $[URL1]',
  56.     '',
  57.     'This program is free software; you can redistribute it and/or',
  58.     'modify it under the terms of the GNU General Public License',
  59.     'as published by the Free Software Foundation; either version 2',
  60.     'of the License, or (at your option) any later version.',
  61.     '',
  62.     'This program is distributed in the hope that it will be useful,',
  63.     'but WITHOUT ANY WARRANTY; without even the implied warranty of',
  64.     'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the',
  65.     'GNU General Public License for more details.',
  66.     '',
  67.     'You should have received a copy of the GNU General Public License',
  68.     'along with this program; if not, write to the Free Software',
  69.     'Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.',
  70.     ''
  71.   );
  72.   if (Documents.Count == 0) {
  73.     return false;
  74.   };
  75.   var def;
  76.   if (Project.Loaded) {         // Project is open
  77.     def = Project.FriendlyName;
  78.   } else {
  79.     def = ActiveDocument.Title; // No Project, use filename
  80.   }
  81.   var progname = InputBox('GPL', 'Enter the Name from the Program.', def);
  82.   if (progname != '')
  83.   {
  84.     var x = ActiveDocument.CaretX;
  85.     var y = ActiveDocument.CaretY;
  86.     var t = ActiveDocument.TopLine;
  87.     var id = String.fromCharCode(32, 36, 73, 100, 58, 32, 36);     // Id:
  88.     ActiveDocument.ExecEditCommand(ecEditorTop);
  89.     with (ActiveDocument.Lines) {
  90.       Insert(0, '');
  91.       Insert(0, id);
  92.       var d = new Date();
  93.       for (var i = gpl.length - 1; i >= 0; i--) {
  94.         if (gpl[i] != '') {
  95.           var instext = new String(gpl[i]);
  96.           instext = instext.replace(/\$\[Project\]/g, progname);
  97.           instext = instext.replace(/\$\[Author\]/g, Author);
  98.           instext = instext.replace(/\$\[Email\]/g, Email);
  99.           instext = instext.replace(/\$\[FileTitle\]/g, ActiveDocument.Title);
  100.           instext = instext.replace(/\$\[Date\]/g, d.toUTCString());
  101.           instext = instext.replace(/\$\[Year\]/g, d.getYear());
  102.           instext = instext.replace(/\$\[Contribs\]/g, Contribs);
  103.           instext = instext.replace(/\$\[URL1\]/g, URL1);
  104.           Insert(0, '  ' + instext);
  105.         } else {
  106.           Insert(0, '');
  107.         }
  108.       }
  109.     }
  110.     ActiveDocument.SelectRange(1, 1, 1, gpl.length + 1);
  111.     ActiveDocument.ExecCommand(scEComment);                            // Comment it
  112.     ActiveDocument.SelectRange(1, 1, 1, 1);
  113. //    ActiveDocument.CaretX = x;
  114. //    ActiveDocument.CaretY = y + gpl.length;
  115. //    ActiveDocument.TopLine = t + gpl.length;
  116.     ActiveDocument.Modified = true;
  117.     return true;
  118.   } else {
  119.     return false;
  120.   }
  121. }
  122.